package com.chagee.store.operation.server.facade;

import com.chagee.base.utils.PaginationData;
import com.chagee.base.utils.PaginationRequest;
import com.chagee.store.operation.server.model.info.LarkMessageInfo;
import com.chagee.store.operation.server.model.param.*;
import com.chagee.store.operation.server.model.vo.AppealReviewerRecordVO;
import com.chagee.store.operation.server.model.vo.EmployeeVo;
import com.chagee.store.operation.server.service.biz.AppealReviewerBizService;
import com.chagee.store.operation.server.service.biz.FeiShuMessageBizService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author: yuanzhiqin
 * @description:
 * @date: 2024/6/27.
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class AppealReviewerFacade {

	@Resource
	private AppealReviewerBizService appealReviewerBizService;

	@Resource
	private FeiShuMessageBizService feiShuMessageBizService;

	/**
	 * 新建申诉人配置
	 * @param param
	 */
	public void addAppealReviewer(AddAppealReviewerParam param){
		appealReviewerBizService.addAppealReviewer(param);
	}

	/**
	 * 分页查询申诉人信息
	 *
	 * @param request
	 * @return
	 */
	public PaginationData<AppealReviewerRecordVO> pageQueryAppealReviewer(PaginationRequest<AppealReviewerListParam> request) {
		return appealReviewerBizService.pageQueryAppealReviewer(request);
	}

	/**
	 * 删除申诉人配置
	 * @param reviewerId
	 */
	public Boolean deleteAppealReviewer(String reviewerId){
		return appealReviewerBizService.deleteAppealReviewer(reviewerId);
	}

	/**
	 * 模糊查询人员信息
	 * @param param
	 */
	public PaginationData<EmployeeVo> queryReviewer(QueryReviewerParam param){
		return appealReviewerBizService.queryReviewer(param);
	}

	/**
	 * 发送飞书消息
	 * @param storeNo
	 * @param workOrderNumber
	 * @return
	 */
	public Boolean sendMessage(String storeNo, String workOrderNumber, String orderCreateTime, String taskName,String type) {
		//发送飞书通知
		LarkMessageInfo info =new LarkMessageInfo();
		info.setStoreNo(storeNo);
		info.setWorkOrderNumber(workOrderNumber);
		info.setOrderCreateTime(orderCreateTime);
		info.setTaskName(taskName);
		info.setType(type);
		try {
			return feiShuMessageBizService.sendMessage(info);
		} catch (Exception e) {
			log.error("打烊工单{}发送飞书通知失败:", workOrderNumber,e);
		}
		return Boolean.TRUE;
	}

	public Boolean updateAppealReviewer(UpdateAppealReviewerParam param) {
		return appealReviewerBizService.updateAppealReviewer(param);
	}


}
